<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<!--[if lt IE 9]>
{js href="/static/admin/lib/html5shiv.js,/static/admin/lib/respond.min.js"}
<![endif]-->
{css href="/static/admin/static/h-ui/css/H-ui.min.css,/static/admin/static/h-ui.admin/css/H-ui.admin.css,/static/admin/lib/Hui-iconfont/1.0.8/iconfont.css,/static/admin/static/h-ui.admin/skin/default/skin.css,/static/admin/static/h-ui.admin/css/style.css"}
<!--[if IE 6]>
{js href="/static/admin/lib/DD_belatedPNG_0.0.8a-min.js"}
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
<title>编辑菜单 - 管理员管理</title>
</head>
<body>
<article class="page-container">
	{if $data}
		<form class="form form-horizontal" id="form-admin-edit" action="/admin/admin/menus/{$data.id}">
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>菜单名称：</label>
				<div class="formControls col-xs-8 col-sm-9">
					<input type="text" class="input-text" value="{$data.name}" placeholder="" id="name" name="name">
				</div>
			</div>
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>菜单路径：</label>
				<div class="formControls col-xs-8 col-sm-9">
					<input type="text" class="input-text" value="{$data.path}" placeholder="" id="path" name="path">
				</div>
			</div>
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>排序：</label>
				<div class="formControls col-xs-8 col-sm-9">
					<input type="text" class="input-text" value="{$data.sort_num}" placeholder="" id="sort_num" name="sort_num">
				</div>
			</div>
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>菜单级别：</label>
				<div class="formControls col-xs-8 col-sm-9">
					<input type="number" class="input-text" value="{$data.level}" placeholder="" id="level" name="level" min="1" max="2">
				</div>
			</div>
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>状态：</label>
				<div class="formControls col-xs-8 col-sm-9 skin-minimal">
					{foreach $status as $key => $_status}
					<div class="radio-box">
						<input name="status" type="radio" id="status-{$key}" {if $key==$data.status}checked{/if} value="{$key}">
						<label for="status-{$key}">{$_status}</label>
					</div>
					{/foreach}
				</div>
			</div>
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>图标：</label>
				<div class="formControls col-xs-8 col-sm-9">
					<input type="text" class="input-text" value="{$data.icon}" readonly placeholder="" id="icon" name="icon" onclick="showIcon(this)">
				</div>
			</div>
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>二级菜单：</label>
				<div class="formControls col-xs-8 col-sm-9">
					<span class="select-box" style="width:150px;">
						<select class="select" name="category_id[]" size="5" multiple>
							<option value="" >请选择</option>
							{foreach $category as $_category}
								<option value="{$_category['id']}" {if in_array($_category['id'], $menuCategory)}selected{/if} >{$_category['name']}</option>
							{/foreach}
						</select>
					</span>
				</div>
			</div>
			{if can('admin/admin/Menus/update')}
				<div class="row cl">
					<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
						<input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
					</div>
				</div>
			{/if}
		</form>
	{/if}
</article>

<!--_footer 作为公共模版分离出去-->
{js href="/static/admin/lib/jquery/1.9.1/jquery.min.js,/static/admin/lib/layer/2.4/layer.js,/static/admin/static/h-ui/js/H-ui.min.js,/static/admin/static/h-ui.admin/js/H-ui.admin.js"}
<!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
{js href="/static/admin/lib/jquery.validation/1.14.0/jquery.validate.js,/static/admin/lib/jquery.validation/1.14.0/validate-methods.js,/static/admin/lib/jquery.validation/1.14.0/messages_zh.js,/static/admin/static/gloab.js,/static/admin/static/gloab.css"}
<script type="text/javascript">
$(function(){
	$('.skin-minimal input').iCheck({
		checkboxClass: 'icheckbox-blue',
		radioClass: 'iradio-blue',
		increaseArea: '20%'
	});

    $('.textarea').Huitextarealength({
        maxlength:100
    });
	
	$("#form-admin-edit").validate({
		rules:{
            name:{
                remote:{
                    url:'/admin/admin/menus/only',
                    type:'get',
                    data:{
                        name:function(){
                            return $("#name").val();
                        },
						id:function(){
							return '{$data.id}'
                        }
                    }
                },
                required:true,
                minlength: 2,
                maxlength: 18
            },
            status:{
                required: true,
                range:[0,1]
            }
		},
		onkeyup:false,
		focusCleanup:true,
		success:"valid",
		submitHandler:function(form){
			$(form).ajaxSubmit({
				type: 'put',
                url: $(form).attr('action'),
                data: $(form).serialize(),
                success:function(data){
					layer.msg('编辑成功',{icon:1,time:1000});
                },
                error:function(XmlHttpRequest, textStatus, errorThrown){
                    let errstr = XmlHttpRequest.responseText;
                    if ( errstr ) {
                        layer.msg($.parseJSON(errstr).message,{icon:5,time:1000});
                    } else {
                        layer.msg('服务错误!',{icon:5,time:1000});
                    }
                }
			});
			// var index = parent.layer.getFrameIndex(window.name);
			// parent.$('.btn-refresh').click();
			// parent.layer.close(index);
			return false;
		}
	});
	{if !$data}
    	layer.msg('资源不存在',{icon:5,time:2000});
	{/if}
});
</script> 
<!--/请在上方写此页面业务相关的脚本-->
</body>
</html>